package com.jian.android.autojipai.app.helper;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.jian.android.autojipai.R;

public class ToastTool {

    public static class ToastToolInstance {
        private static final ToastTool instance = new ToastTool();

        private ToastToolInstance() {
        }
    }

    private ToastTool() {
    }

    public static ToastTool getInstance() {
        return ToastToolInstance.instance;
    }

    public void show(Context context, String str) {
        if (TextUtils.isEmpty(str) || context == null) {
            return;
        }
        try {
            Toast toast = Toast.makeText(context, str, Toast.LENGTH_SHORT);
            View inflate = LayoutInflater.from(context).inflate(R.layout.layout_toast, (ViewGroup) null);
            ((TextView) inflate.findViewById(R.id.tv_toast)).setText(str);
            toast.setView(inflate);
            toast.setGravity(17, 0, 0);
            toast.show();
        } catch (Exception e2) {
            Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
        }
    }
}
